      SUBROUTINE E02AHF(NP1,XMIN,XMAX,A,IA1,LA,PATM1,ADIF,IADIF1,LADIF,
     *                  IFAIL)
C     MARK 8 RELEASE. NAG COPYRIGHT 1979.
C     MARK 11.5(F77) REVISED. (SEPT 1985.)
C
C     * * * * * * * * * * * * * * * * * * * * * * * * * * * *
C
C     NPL DATA FITTING LIBRARY ROUTINE CHBDIF
C
C     CREATED 1/5/79    UPDATED 23/1/80     RELEASE NO. 00/03
C
C     AUTHORS.. GERALD T ANTHONY, MAURICE G COX, J GEOFFREY HAYES.
C     NATIONAL PHYSICAL LABORATORY
C     TEDDINGTON, MIDDLESEX, ENGLAND.
C
C     * * * * * * * * * * * * * * * * * * * * * * * * * * * *
C
C     INPUT PARAMETERS
C        NP1    = N+1 WHERE N IS DEGREE OF GIVEN POLYNOMIAL
C        XMIN   LOWER LIMIT OF RANGE OF X
C        XMAX   UPPER LIMIT OF RANGE OF X
C        A      COEFFICIENTS A0, A1,...AN OF THE GIVEN POLYNOMIAL
C        IA1       ARE STORED IN ARRAY A IN POSITIONS 1, 1+IA1,...
C                  1+N*IA1, RESPECTIVELY
C        LA     THE DECLARED DIMENSION OF ARRAY A
C
C     OUTPUT PARAMETERS
C        PATM1  THE VALUE OF THE GIVEN POLYNOMIAL AT XMIN
C        ADIF   THE COEFFICIENTS OF THE DERIVATIVE POLYNOMIAL
C        IADIF1    ARE RETURNED IN ARRAY ADIF IN POSITIONS
C                  1, 1+IADIF1,...1+(N-1)*IADIF1
C        LADIF  THE DECLARED DIMENSION OF ARRAY ADIF
C        IFAIL  ERROR INDICATOR
C
C     DIFFERENTIATE THE SERIES WITH COEFFICIENTS A OF DEGREE N
C     (I.E. NP1 COEFFICIENTS) TO OBTAIN THE SERIES WITH COEFFICIENTS
C     ADIF OF DEGREE N-1. ALSO SET NEXT HIGHER COEFFICIENT TO ZERO.
C
C     .. Parameters ..
      CHARACTER*6       SRNAME
      PARAMETER         (SRNAME='E02AHF')
C     .. Scalar Arguments ..
      DOUBLE PRECISION  PATM1, XMAX, XMIN
      INTEGER           IA1, IADIF1, IFAIL, LA, LADIF, NP1
C     .. Array Arguments ..
      DOUBLE PRECISION  A(LA), ADIF(LADIF)
C     .. Local Scalars ..
      INTEGER           IERROR, N
C     .. Local Arrays ..
      CHARACTER*1       P01REC(1)
C     .. External Functions ..
      INTEGER           P01ABF
      EXTERNAL          P01ABF
C     .. External Subroutines ..
      EXTERNAL          E02AHZ
C     .. Executable Statements ..
      N = NP1 - 1
      IERROR = 1
      IF ( .NOT. (NP1.GE.1 .AND. XMAX.GT.XMIN .AND. IA1.GE.1 .AND.
     *    LA.GT.N*IA1 .AND. IADIF1.GE.1 .AND. LADIF.GT.N*IADIF1))
     *    GO TO 20
      IERROR = 0
      CALL E02AHZ(NP1,XMIN,XMAX,A,IA1,LA,PATM1,ADIF,IADIF1,LADIF)
   20 IFAIL = P01ABF(IFAIL,IERROR,SRNAME,0,P01REC)
      RETURN
C     END E02AHF
      END
